//
//  ViewController.m
//  XSDownloadDemo
//
//  Created by 大帅 on 2023/12/21.
//

#import "ViewController.h"

#import "XSM3u8ListViewController.h"        // M3u8视频列表
#import "XSM3u8DownloadViewController.h"    // M3u8下载列表
#import "XSCustomTaskViewController.h"      // 自定义下载地址

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"home";
    self.view.backgroundColor = [UIColor.greenColor colorWithAlphaComponent:0.5];
    
    
    CGFloat temp_y = 100;
    NSArray *arr = @[@"视频列表", @"下载列表", @"custom-url"];
    for (int i = 0; i < arr.count; i ++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:arr[i] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setBackgroundColor:[UIColor whiteColor]];
        button.tag = i + 100;
        [button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(20);
            make.top.mas_equalTo(temp_y + (45 + 20) * i);
            make.size.mas_offset(CGSizeMake(150, 45));
        }];
    }
    
}

-(void)clickButton:(UIButton *)sender {
    if (sender.tag == 100) {
        // M3u8视频列表
        XSM3u8ListViewController *vc = [[XSM3u8ListViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (sender.tag == 101) {
        // M3u8下载列表
        XSM3u8DownloadViewController *vc = [[XSM3u8DownloadViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (sender.tag == 102) {
        // 自定义下载视频地址
        XSCustomTaskViewController *vc = [[XSCustomTaskViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}


@end
